#!/bin/sh
# startup script for indexmaker

@project.artifactId@_HOME=${IM_HOME:-"/usr/local/share/java/@project.artifactId@"}


#-----------------------------------------------------------------------------
# Determine configuration settings
#-----------------------------------------------------------------------------

# Load user-specific log4j configuration
if [ -f "${@project.artifactId@_HOME}/log4j.properties" ]; then 
	DARGS="-Dlog4j.configuration=file:${@project.artifactId@_HOME}/log4j.properties"
fi

#echo ${DARGS}

# Load programm configuration
if [ -f "${@project.artifactId@_HOME}/@project.artifactId@.properties" ]; then 
	DARGS="${DARGS} -Dim.cfg=file:${@project.artifactId@_HOME}/@project.artifactId@.properties"
fi 

#echo ${DARGS}

#-----------------------------------------------------------------------------
# classpath
#-----------------------------------------------------------------------------

LCP=${@project.artifactId@_HOME}/@project.build.finalName@.jar

for l in ${@project.artifactId@_HOME}/lib/*.jar
    do
	LCP="${LCP}:${l}"
done

#-----------------------------------------------------------------------------
# Execute
#-----------------------------------------------------------------------------
case "`uname`" in
     FreeBSD*)
	JAVACMD="${JAVACMD:-"/usr/local/bin/java"}"
	;;
    *) 
	JAVACMD=`which java 2>/dev/null`
	;;
esac

if [ ! -x "${JAVACMD}" ]; then
    echo "Error: ${JAVACMD} is not present on your system" >&2
    echo "       Please specify the path to an existing java executable with the" >&2
    echo "       JAVACMD environment variable when running this." >&2
    exit 1
fi
	

#echo "${JAVACMD}" ${DARGS} -classpath "${LCP}" com.crimsec.utils.dinfo.App "$@"
                                        
exec "${JAVACMD}" ${DARGS} -classpath "${LCP}" com.crimsec.utils.dinfo.App "$@"
